/**
 * 
 */
package com.itmayiedu.entity;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonView;
import com.itmayiedu.annotation.IsMobile;
import com.itmayiedu.annotation.MyConstraint;

import lombok.Data;
import lombok.ToString;

/**
 * @author Administrator
 * @date 2019年5月2日
 */

@Data
@ToString
@Entity
@Table(name="t_user")
public class User {

	
	//配合@JsonView 来控制JSON输出内容
	public interface UserSimpleView{};
	//有了该继承关系，在显示detail视图的时候同时会把simple视图的所有字段也显示出来
	public interface UserDetailView extends UserSimpleView{};
	
	@Id
	@GeneratedValue
	@Column(name="t_id")
	@JsonView(UserSimpleView.class)
	private Integer id;
	
	@Column(name="t_name")
	@MyConstraint(message="名字不能为空")
	@JsonView(UserSimpleView.class)
	private String name;
	
	@Column(name="t_password")
	@NotBlank(message="密码不能为空")
	@JsonView(UserDetailView.class)
	private String password;

	@Column(name="t_mobile")
	@JsonView(UserDetailView.class)
	@IsMobile
	private String mobile;
	
	/**
	 * @param id
	 * @param name
	 * @param password
	 */
	public User(int id, String name, String password,String mobile) {
		super();
		this.id = id;
		this.name = name;
		this.password = password;
	}
	
	public User() {
		
	}
}
